/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package presentationTier.actions;

import businessTier.IMovieFacade;
import businessTier.MovieFacade;
import core.Genre;
import core.MovieException;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;
import presentationTier.dialogs.ChangeGenreDialog;

/**
 *
 * @author vojta
 */
public class ChangeGenreChangeAction implements ActionListener{

    ChangeGenreDialog dialog;

    public ChangeGenreChangeAction(ChangeGenreDialog aThis) {
        dialog = aThis;
    }

    public void actionPerformed(ActionEvent e) {
        Genre genre = (Genre) dialog.jComboBox1.getSelectedItem();
        String name = genre.getGenre();

        String result = JOptionPane.showInputDialog("Change genre name to: ", name);
        //JOptionPane.showMessageDialog(dialog, result);
        if (!result.equalsIgnoreCase("")) {
            try {
                genre.setGenre(result);
                IMovieFacade mf = MovieFacade.getInstance();
                mf.changeGenre(genre);
                mf.close();

                dialog.readGenres();

            } catch (MovieException ex) {
                
            }


        }
    }

}
